"""
tcp 服务端
"""
from socket import *
# 创建服务器地址和端口元组
ADDR = ("0.0.0.0",8888)
# 创建Tcp对象
tcp_socket = socket(AF_INET,SOCK_STREAM)

# 绑定端口
tcp_socket.bind(ADDR)

# 监听客户端
tcp_socket.listen(5)

# 允许循环创建连接
while True:
    print("等待连接中......")
    conn,addr = tcp_socket.accept()
    print("连接成功了......",addr)

    while True:
        data = conn.recv(1024)
        if not data or data == b'##':
            break
        print("收到：",data.decode())
        conn.send(b"Thanks")
    conn.close()

tcp_socket.close()





